#include "databreakpointdlg.h"
#include "debugger_defs.h"
#include <wx/button.h>
#include <wx/string.h>
#include <wx/intl.h>

const long DataBreakpointDlg::ID_CHK_ENABLED = wxNewId();
const long DataBreakpointDlg::ID_TXT_DATA_EXPRESION = wxNewId();
const long DataBreakpointDlg::ID_RDO_CONDITION = wxNewId();

BEGIN_EVENT_TABLE( DataBreakpointDlg, wxScrollingDialog )
END_EVENT_TABLE()

DataBreakpointDlg::DataBreakpointDlg( wxWindow *parent, const wxString& dataExpression, bool enabled, int selection ) {
  wxBoxSizer* bszMain;
  Create( parent, wxID_ANY, _T( "Data breakpoint" ), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T( "wxID_ANY" ) );
  bszMain = new wxBoxSizer( wxVERTICAL );
  m_enabled = new wxCheckBox( this, ID_CHK_ENABLED, _T( "Enabled" ), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T( "ID_CHK_ENABLED" ) );
  m_enabled->SetValue( false );
  bszMain->Add( m_enabled, 0, wxTOP | wxLEFT | wxRIGHT | wxEXPAND, 8 );
  m_dataExpression = new wxTextCtrl( this, ID_TXT_DATA_EXPRESION, wxEmptyString, wxDefaultPosition, wxSize( 265, 23 ), wxTE_PROCESS_ENTER, wxDefaultValidator, _T( "ID_TXT_DATA_EXPRESION" ) );
  m_dataExpression->SetFocus();
  bszMain->Add( m_dataExpression, 1, wxTOP | wxLEFT | wxRIGHT | wxEXPAND, 8 );
  wxString __wxRadioBoxChoices_1[3] = {
    _T( "Break on read" ),
    _T( "Break on write" ),
    _T( "Break on read or write" )
  };
  m_condition = new wxRadioBox( this, ID_RDO_CONDITION, _T( "Condition" ), wxDefaultPosition, wxDefaultSize, 3, __wxRadioBoxChoices_1, 1, 0, wxDefaultValidator, _T( "ID_RDO_CONDITION" ) );
  bszMain->Add( m_condition, 0, wxTOP | wxLEFT | wxRIGHT | wxEXPAND, 8 );
  StdDialogButtonSizer1 = new wxStdDialogButtonSizer();
  StdDialogButtonSizer1->AddButton( new wxButton( this, wxID_OK, wxEmptyString ) );
  StdDialogButtonSizer1->AddButton( new wxButton( this, wxID_CANCEL, wxEmptyString ) );
  StdDialogButtonSizer1->Realize();
  bszMain->Add( StdDialogButtonSizer1, 0, wxALL | wxEXPAND, 8 );
  SetSizer( bszMain );
  bszMain->Fit( this );
  bszMain->SetSizeHints( this );
  Center();
  m_enabled->SetValue( enabled );
  m_condition->SetSelection( selection );
  m_dataExpression->SetValue( dataExpression );
}

DataBreakpointDlg::~DataBreakpointDlg() {
}

bool DataBreakpointDlg::IsBreakpointEnabled() {
  return m_enabled->IsChecked();
}

int DataBreakpointDlg::GetSelection() {
  return m_condition->GetSelection();
}

wxString DataBreakpointDlg::GetDataExpression() const {
  return CleanStringValue( m_dataExpression->GetValue() );
}
